package com.tongren.framework.maintabfragment;


import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.tongren.framework.R;
import com.tongren.framework.core.BaseFragment;
import com.tongren.framework.core.CustomApplication;
import com.tongren.framework.core.ITabFragment;
import com.tongren.framework.me.activity.CourseTalbeActivity;
import com.tongren.framework.me.activity.LoginActivity;
import com.tongren.framework.me.activity.MyClassWorkListActivity;
import com.tongren.framework.me.activity.MyWorkListActivity;
import com.tongren.framework.me.activity.WebViewActivity;
import com.tongren.framework.me.activity.WrongBookListActivity;
import com.tongren.framework.model.BaseUser;


/**
 * A simple {@link Fragment} subclass.
 */
public class MeFragment extends BaseFragment implements ITabFragment ,View.OnClickListener{

    private TextView tv_login;
    private TextView tv_school;
    private TextView tv_name;

    private RelativeLayout relative_myclasswork;
    private RelativeLayout relative_course_table;
    private RelativeLayout relative_my_work;
    private RelativeLayout relative_wrong_book;
    private RelativeLayout relative_share_work;

    public MeFragment() {
        // Required empty public constructor
    }


    @Override
    public void setUpView(View view) {
        tv_name = (TextView) view.findViewById(R.id.tv_name);
        tv_school = (TextView) view.findViewById(R.id.tv_school);

        tv_login = (TextView) view.findViewById(R.id.tv_login);
        tv_login.setOnClickListener(this);

        relative_wrong_book = (RelativeLayout) view.findViewById(R.id.relative_wrong_book);
        relative_wrong_book.setOnClickListener(this);

        relative_course_table = (RelativeLayout) view.findViewById(R.id.relative_course_table);
        relative_course_table.setOnClickListener(this);

        relative_myclasswork = (RelativeLayout) view.findViewById(R.id.relative_myclasswork);
        relative_myclasswork.setOnClickListener(this);

        relative_my_work = (RelativeLayout) view.findViewById(R.id.relative_my_work);
        relative_my_work.setOnClickListener(this);

        relative_share_work = (RelativeLayout) view.findViewById(R.id.relative_share_work);
        relative_share_work.setOnClickListener(this);
    }

    @Override
    public void setUpData() {
        BaseUser user = CustomApplication.getInstance().getUserModel();
        tv_name.setText(user.getYhmc());
        tv_school.setText(user.getDwmc());
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        return inflater.inflate(R.layout.fragment_me, container, false);
    }

    @Override
    public void onMenuItemClick() {

    }

    @Override
    public BaseFragment getFragment() {
        return this;
    }


    @Override
    public void onClick(View view) {
        switch(view.getId()){
            case R.id.tv_login:
                Intent intent = new Intent(getActivity(),LoginActivity.class);
                startActivity(intent);
                break;
            case R.id.relative_myclasswork:
                Intent intent1 = new Intent(getActivity(),MyClassWorkListActivity.class);
                startActivity(intent1);
                break;
            case R.id.relative_course_table:
                Intent intent2 = new Intent(getActivity(),CourseTalbeActivity.class);
                startActivity(intent2);
                break;
            case R.id.relative_my_work:
                Intent intent3 = new Intent(getActivity(),MyWorkListActivity.class);
                startActivity(intent3);
                break;
            case R.id.relative_share_work:
                Intent intent4 = new Intent(getActivity(),MyWorkListActivity.class);
                startActivity(intent4);
                break;
            case R.id.relative_wrong_book:
                Intent intent5 = new Intent(getActivity(),WrongBookListActivity.class);
                startActivity(intent5);
                break;
        }
    }
}
